<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div class="a1">
      <a class="a2" href="https://www.baidu.com">11fdsafadf1</a>
    </div>
    <script>
      let arr = [2, 3, 4, 5, 6, 7, 8, 1];
      let count = 0;
      function quickSort(arr) {
        if (arr.length <= 1) {
          return arr;
        }
        let pivotIndex = Math.floor(arr.length / 2);
        let pivot = arr.splice(pivotIndex, 1)[0];
        let left = [];
        let right = [];
        for (let i = 0; i < arr.length; i++) {
          count++;
          if (arr[i] < pivot) {
            left.push(arr[i]);
          } else {
            right.push(arr[i]);
          }
        }
        return quickSort(left).concat([pivot], quickSort(right));
      }
      console.log(quickSort(arr), `运行了${count}次`); //[1,2,3,4,5,6,7,8] 运行了15次
    </script>
  </body>
</html>
